package com.satis.compose.get.navigator
import androidx.compose.runtime.Composable
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.remember
import androidx.navigation.*
import androidx.navigation.compose.rememberNavController

/**
 * Creates a NavHostController that handles the adding of the [ComposeNavigator], [DialogNavigator]
 * and [GetAnimatedComposeNavigator]. Additional [androidx.navigation.Navigator] instances should be
 * added in a [androidx.compose.runtime.SideEffect] block.
 *
 * @see [GetAnimatedNavHost]
 */
@Composable
internal fun rememberGetAnimatedNavController(
    vararg navigators: Navigator<out NavDestination>
): NavHostController {
    val animatedNavigator = remember { GetAnimatedComposeNavigator() }
    return rememberNavController(animatedNavigator, *navigators)
}

/**
 * activity 级别导航器缓存
 */
val LocalNavHostController = compositionLocalOf<NavHostController> { error("LocalNavHostController is null") }

